<?php

	require_once(TOOLKIT . '/class.event.php');
	
	Class eventadmin_edit_time_schedule extends Event{
		
		const ROOTELEMENT = 'admin-edit-time-schedule';
		
		public $eParamFILTERS = array(
			
		);
			
		public static function about(){
			return array(
					 'name' => 'Admin Edit Time Schedule',
					 'author' => array(
							'name' => 'J G',
							'website' => 'http://localhost:8888/corvallispt.dev',
							'email' => 'elixai@gmail.com'),
					 'version' => '1.0',
					 'release-date' => '2010-01-19T22:06:50+00:00',
					 'trigger-condition' => 'action[admin-edit-time-schedule]');	
		}

		public static function getSource(){
			return '13';
		}

		public static function allowEditorToParse(){
			return true;
		}

		public static function documentation(){
			return '
        <h3>Success and Failure XML Examples</h3>
        <p>When saved successfully, the following XML will be returned:</p>
        <pre class="XML"><code>&lt;admin-edit-time-schedule result="success" type="create | edit">
  &lt;message>Entry [created | edited] successfully.&lt;/message>
&lt;/admin-edit-time-schedule></code></pre>
        <p>When an error occurs during saving, due to either missing or invalid fields, the following XML will be returned:</p>
        <pre class="XML"><code>&lt;admin-edit-time-schedule result="error">
  &lt;message>Entry encountered errors when saving.&lt;/message>
  &lt;field-name type="invalid | missing" />
  ...
&lt;/admin-edit-time-schedule></code></pre>
        <h3>Example Front-end Form Markup</h3>
        <p>This is an example of the form markup you can use on your frontend:</p>
        <pre class="XML"><code>&lt;form method="post" action="" enctype="multipart/form-data">
  &lt;input name="MAX_FILE_SIZE" type="hidden" value="5242880" />
  &lt;label>Weekday
    &lt;input name="fields[weekday]" type="text" />
  &lt;/label>
  &lt;label>Available Times
    &lt;select name="fields[available-times][]" multiple="multiple">
      &lt;option value="None">None&lt;/option>
      &lt;option value="08:00">08:00&lt;/option>
      &lt;option value="08:15">08:15&lt;/option>
      &lt;option value="08:30">08:30&lt;/option>
      &lt;option value="08:45">08:45&lt;/option>
      &lt;option value="09:00">09:00&lt;/option>
      &lt;option value="09:15">09:15&lt;/option>
      &lt;option value="09:30">09:30&lt;/option>
      &lt;option value="09:45">09:45&lt;/option>
      &lt;option value="10:00">10:00&lt;/option>
      &lt;option value="10:15">10:15&lt;/option>
      &lt;option value="10:30">10:30&lt;/option>
      &lt;option value="10:45">10:45&lt;/option>
      &lt;option value="11:00">11:00&lt;/option>
      &lt;option value="11:15">11:15&lt;/option>
      &lt;option value="11:30">11:30&lt;/option>
      &lt;option value="11:45">11:45&lt;/option>
      &lt;option value="12:00">12:00&lt;/option>
      &lt;option value="12:15">12:15&lt;/option>
      &lt;option value="12:30">12:30&lt;/option>
      &lt;option value="12:45">12:45&lt;/option>
      &lt;option value="13:00">13:00&lt;/option>
      &lt;option value="13:15">13:15&lt;/option>
      &lt;option value="13:30">13:30&lt;/option>
      &lt;option value="13:45">13:45&lt;/option>
      &lt;option value="14:00">14:00&lt;/option>
      &lt;option value="14:15">14:15&lt;/option>
      &lt;option value="14:30">14:30&lt;/option>
      &lt;option value="14:45">14:45&lt;/option>
      &lt;option value="15:00">15:00&lt;/option>
      &lt;option value="15:15">15:15&lt;/option>
      &lt;option value="15:30">15:30&lt;/option>
      &lt;option value="15:45">15:45&lt;/option>
      &lt;option value="16:00">16:00&lt;/option>
      &lt;option value="16:15">16:15&lt;/option>
      &lt;option value="16:30">16:30&lt;/option>
      &lt;option value="16:45">16:45&lt;/option>
      &lt;option value="17:00">17:00&lt;/option>
      &lt;option value="17:15">17:15&lt;/option>
      &lt;option value="17:30">17:30&lt;/option>
      &lt;option value="17:45">17:45&lt;/option>
      &lt;option value="18:00">18:00&lt;/option>
    &lt;/select>
  &lt;/label>
  &lt;label>Session Length
    &lt;select name="fields[session-length]">
      &lt;option value="None">None&lt;/option>
      &lt;option value="1 hour">1 hour&lt;/option>
      &lt;option value="1 hour 15 mins">1 hour 15 mins&lt;/option>
      &lt;option value="1 hour 30 mins">1 hour 30 mins&lt;/option>
      &lt;option value="2 hours">2 hours&lt;/option>
      &lt;option value="2 hours 30 mins">2 hours 30 mins&lt;/option>
    &lt;/select>
  &lt;/label>
  &lt;input name="action[admin-edit-time-schedule]" type="submit" value="Submit" />
&lt;/form></code></pre>
        <p>To edit an existing entry, include the entry ID value of the entry in the form. This is best as a hidden field like so:</p>
        <pre class="XML"><code>&lt;input name="id" type="hidden" value="23" /></code></pre>
        <p>To redirect to a different location upon a successful save, include the redirect location in the form. This is best as a hidden field like so, where the value is the URL to redirect to:</p>
        <pre class="XML"><code>&lt;input name="redirect" type="hidden" value="http://localhost:8888/corvallispt.dev/success/" /></code></pre>';
		}
		
		public function load(){			
			if(isset($_POST['action']['admin-edit-time-schedule'])) return $this->__trigger();
		}
		
		protected function __trigger(){
			include(TOOLKIT . '/events/event.section.php');
			return $result;
		}		

	}

